-
Notifications
You must be signed in to change notification settings - Fork 16
fix(container): strip headers from logs using log stream specification #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates log handling to comply with the Docker log stream specification by stripping the 8-byte headers for multiplexed stdout/stderr streams and adds tests to verify correct behavior in both TTY and non-TTY modes.
- Added TTY detection in
Logsand a newparseMultiplexedLogsfunction to strip stream headers - Introduced comprehensive tests in
container.logs_test.gofor header stripping, stderr handling, error logging, and TTY mode - Removed the old
ReadLine-based trimming logic and replaced it withio.ReadFull/io.CopyNframe parsing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| container/container.logs.go | Detect TTY, route logs through a new binary-frame parser |
| container/container.logs_test.go | New tests verifying header stripping, stderr, errors, and TTY |
Comments suppressed due to low confidence (1)
container/container.logs.go:23
- Inside the
containerpackage you should refer toLogsOptionswithout qualifying it withcontainer. Changecontainer.LogsOptionstoLogsOptionsfor proper compilation.
options := container.LogsOptions{
What does this PR do?
According to the log stream specification, the last 4 bytes of the header indicate the length of the log frame. There is an issue when a log message is exactly 10 character long, the header ends with \00\00\00\10. The current implementation uses ReadLine so it doesn't correctly read the header which results in the header being output. This is what the it looks like with the new test:
Why is it important?
Related issues